/******************* (C) COPYRIGHT 2022 CHU WEI TENG ***********************************************
**
**------------------ File Info ---------------------------------------------------------------------
** File name:      main_windows.c
** modified Date:  2022-05-10
** Last Version:   V1.0
** Descriptions: 
** 
**------------------ Modfication  log --------------------------------------------------------------
** Date       Who            Rev        Comments
----------------------------------------------------------------------------------------------------
   22/05/10 chuwt@qq.com    V1.00      created

****************************************************************************************************/
#include "main_windows.h"

/* Private define----------------------------------------------------------------------------------*/

/* Private typedef---------------------------------------------------------------------------------*/

/* Private variables-------------------------------------------------------------------------------*/
static ret_t event_page_func(dwin_widget_t* widget);

dwin_widget_vtable_t  main_windows_vt = 
{
    .obj_size = sizeof(main_windows_t),
};

/* public function---------------------------------------------------------------------------------*/
dwin_widget_t* main_windows_create(dwin_widget_t* parent)
{
    dwin_widget_t* widget = dwin_widget_create(parent, &main_windows_vt, 0);

    if (widget != NULL)
    {
        main_windows_t*  windows = (main_windows_t *)widget;
        
        dwin_windows_init(widget);

        windows->example_info_page = example_info_page_create(widget, EXAMPLE_INFO_PAGE_ADDR, 0xFFFF, 2); 
        dwin_windows_widget_add(widget, windows->example_info_page);
        dwin_widget_event_register(windows->example_info_page, EVT_CLICK, event_page_func);
    }
    return widget;
}

static ret_t event_page_func(dwin_widget_t* widget)
{
	return_value_if_fail(widget, RET_BAD_PARAMS);
	
    dwin_page_t*     page = (dwin_page_t *)widget;
    
	dwin_windows_jump(page->page_id);
     
    return RET_OK;
}
